// 省略模式
export default {
  computed: {
    // 计算内容是否溢出
    showEllipsis() {
      // 根据高度计算溢出
      if (this.overflowMode === "height") {
        return this.textHeight > this.parentHeight;
      }
      // 根据行数计算溢出
      const lines = Math.ceil(this.textHeight / this.lineHeight);
      return lines > this.lineClamp;
    },
    // 计算文本内容的高度
    textContainerHeight() {
      // 根据高度计算
      if (this.overflowMode === "height") {
        const lines = this.parentHeight / this.lineHeight;
        let h;
        // 是否省略末尾行
        if (this.showLastLine) {
          h = Math.ceil(lines) * this.lineHeight;
        } else {
          h = Math.floor(lines) * this.lineHeight;
        }
        return Math.min(h, this.parentHeight);
      }
      return Math.min(this.lineClamp * this.lineHeight, this.textHeight);
    },
  },
};
